<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<title>用户登陆</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}

table {
	border-left: 1px #0000FF solid;
	border-top: 1px #0000FF solid;
}

td {
	border-right: 1px #0000FF solid;
	border-bottom: 1px #0000FF solid;
	padding: 5px;
}
</style>
<script type="text/javascript" src="./checklogin.js"></script>
</head>
<body>
	<c:if test="${not empty cookie['username'].value }">
		<c:set value="${cookie['username'].value}" var="username" scope="session"></c:set>
	</c:if>
	<c:if test="${not empty sessionScope.username }">
		<c:redirect url="./UserList"></c:redirect>
	</c:if>
	<p></p>
	<p></p>
	<form id="login" name="login" method="get" action="./LoginProcess"
		onsubmit="return checkLogin()">
		<table width="350" border="0" align="center" cellspacing="0">
			<tr>
				<td colspan="2" align="center"
					style="font-size: 18px; background-color: #999900">系统登陆</td>
			</tr>
			<tr>
				<td width="99" align="right">用户名</td>
				<td width="240" align="left"><label for="textfield"></label> <input
					type="text" name="username" id="username" /></td>
			</tr>
			<tr>
				<td align="right">密码</td>
				<td align="left"><label for="textfield2"></label> <input
					type="password" name="passwd" id="passwd" /></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input type="checkbox"
					name="flag" id="flag" value="checked" /> <label for="checkbox">
						一个月不用登陆 </label></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input type="submit"
					name="button" id="button" value="提交" /> &nbsp;&nbsp; <input
					type="button" name="button2" id="button2"
					onclick="window.location.replace('./register.jsp')" value="新用户注册" /></td>
			</tr>
		</table>
	</form>
	<c:set value="${param.error}" var="error"></c:set>
	
	<c:if test="${not empty error and error eq 'usererror' }">
		<script>alert("登陆失败：该用户不存在！");</script>
	</c:if>
	
	<c:if test="${not empty error and error eq 'passerror' }">
		<script>alert("登陆失败：密码错误！");</script>
	</c:if>
	
	<c:if test="${not empty error and error eq 'nologin' }">
		<script>alert("请先登录！");</script>
	</c:if>
</body>
</html>
